package cn.iocoder.yudao.module.member.dal.mysql.newsStudyType;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.newsStudyType.NewsStudyTypeDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.newsStudyType.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 新闻栏目(成果类型) Mapper
 *
 * @author 管理员
 */
@Mapper
public interface NewsStudyTypeMapper extends BaseMapperX<NewsStudyTypeDO> {

    default PageResult<NewsStudyTypeDO> selectPage(NewsStudyTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<NewsStudyTypeDO>()
                .likeIfPresent(NewsStudyTypeDO::getName, reqVO.getName())
                .eqIfPresent(NewsStudyTypeDO::getType, reqVO.getType())
                .betweenIfPresent(NewsStudyTypeDO::getReleaseTime, reqVO.getBeginReleaseTime(), reqVO.getEndReleaseTime())
                .eqIfPresent(NewsStudyTypeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(NewsStudyTypeDO::getWeight, reqVO.getWeight())
                .betweenIfPresent(NewsStudyTypeDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(NewsStudyTypeDO::getId));
    }

    default List<NewsStudyTypeDO> selectList(NewsStudyTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<NewsStudyTypeDO>()
                .likeIfPresent(NewsStudyTypeDO::getName, reqVO.getName())
                .eqIfPresent(NewsStudyTypeDO::getType, reqVO.getType())
                .betweenIfPresent(NewsStudyTypeDO::getReleaseTime, reqVO.getBeginReleaseTime(), reqVO.getEndReleaseTime())
                .eqIfPresent(NewsStudyTypeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(NewsStudyTypeDO::getWeight, reqVO.getWeight())
                .betweenIfPresent(NewsStudyTypeDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
                .orderByDesc(NewsStudyTypeDO::getId));
    }

    void updateNewsStudyType(@Param("newsStudyTypeDO") NewsStudyTypeDO newsStudyTypeDO);

    List<NewsStudyTypeDO> getNewsStudyTypeList(IPage page, @Param("params") Map<String, Object> params);

    void updateBatch(@Param("ids") List<Long> ids);

    void updateNewsStudyTypeSort(@Param("list") List<NewsStudyTypeDO> list);
}
